package com.wanxi.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created by IntelliJ IDEA.
 * 代理地址
 * @Author : 林子淳
 * @create 2023/3/15 11:15
 */
@Configuration
public class MyMvcConfig extends WebMvcConfigurationSupport {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //WebMvcConfigurer.super.addResourceHandlers(registry);
        //把静态资源存放的地址src/main/resources/static,直接通过/来访问，如："http://127.0.0.1:8080/"+静态资源名字(aa.jpg)
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/static/");
        //把静态资源存放的地址D://uploadImg/，通过/image/这个路径来访问，如："http://127.0.0.1:8080/image/"+静态资源名字(aa.jpg)
        registry.addResourceHandler("/image/**")
                .addResourceLocations("file:D://uploadImg/");
        super.addResourceHandlers(registry);
    }

}
